package com.grj.parking.aaaa;

/**
 * @author ganru
 * @date 2025/9/9 2:10
 */
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration // 标记为配置类
@EnableConfigurationProperties(LogProperties.class) // 启用配置属性类
public class LogAutoConfiguration {

    // 注入配置属性
    private final LogProperties logProperties;

    public LogAutoConfiguration(LogProperties logProperties) {
        this.logProperties = logProperties;
    }

    // 自动注入 LogService Bean
    // @ConditionalOnMissingBean：如果用户手动定义了 LogService，则不使用当前默认Bean
    @Bean
    @ConditionalOnMissingBean
    public LogService logService() {
        return new LogService(logProperties.getPrefix());
    }
}